Imports ACFramework

Public Class ACGenerarSQL

#Region " Propiedades "
   Public ReadOnly Property Tabla() As String
      Get
         Return "TRAN_VehiculosNeumaticos"
      End Get
   End Property
   Public ReadOnly Property Esquema() As String
      Get
         Return "Transportes"
      End Get
   End Property

#End Region

#Region " Metodos de controles "
   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      Try
         Dim x_vehic_id As Integer = 10

         Dim _join As New List(Of ACJoin)
         _join.Add(New ACJoin("Transportes", "TRAN_Neumaticos", "Neu", ACJoin.TipoJoin.Inner _
                            , New ACCampos() {New ACCampos("NEUMA_ID", "NEUMA_ID")} _
                            , New ACCampos() {New ACCampos("NEUMA_CODIGO", "NEUMA_CODIGO") _
                                            , New ACCampos("NEUMA_MODELO", "NEUMA_MODELO") _
                                            , New ACCampos("NEUMA_TIEMPOVIDAUTIL", "NEUMA_TIEMPOVIDAUTIL") _
                                            , New ACCampos("NEUMA_FECCOMPRA", "NEUMA_FECCOMPRA")}))
         _join.Add(New ACJoin("dbo", "Tipos", "TMar", "Neu", ACJoin.TipoJoin.Inner _
                            , New ACCampos() {New ACCampos("TIPOS_CODIGO", "TIPOS_CODMARCA")} _
                            , New ACCampos() {New ACCampos("TIPOS_DESCRIPCION", "TIPO_MARCA")}))
         Dim _where As New Hashtable()
         _where.Add("VEHIC_ID", New ACWhere(x_vehic_id.ToString(), ACWhere.TipoWhere.Igual))
         _where.Add("VNEUM_ESTADO", New ACWhere("A", ACWhere.TipoWhere.Igual))

         TextBox1.Text = getSelectAll(_join, _where)
      Catch ex As Exception

      End Try
   End Sub
#End Region

   
   Public Function getSelectAll(ByVal x_join As List(Of ACJoin), ByVal x_where As Hashtable) As String
      Dim sql As String = ""
      Try

         Dim _join As New ACGenerador(Of ETRAN_VehiculosNeumaticos)("yyyy-MM-dd")
         sql &= _join.getJoin(Esquema, Tabla, x_join, x_where)

         Return sql
      Catch ex As Exception
         Throw ex
      End Try
   End Function

   Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
      Try
         Dim cprueba As New ETRAN_VehiculosNeumaticos
         '
         'infoTipo(cprueba.GetType)
         cprueba.NEUMA_CODIGO = "00001"
         cprueba.NEUMA_FECCOMPRA = DateTime.Now
         cprueba.NEUMA_ID = -1
         cprueba.NEUMA_MODELO = "ssssss"
         Dim _f As New ACFramework.ACGenerador(Of ETRAN_VehiculosNeumaticos)("yyyy-MM-dd")
         TextBox2.Text = _f.getInsert("esq", "Tabla", cprueba)
      Catch ex As Exception
         MsgBox("Error")
      End Try
   End Sub

   Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
      Try
         Dim cprueba As New ETRAN_VehiculosNeumaticos
         '
         'infoTipo(cprueba.GetType)
         cprueba.NEUMA_CODIGO = "00001"
         cprueba.NEUMA_FECCOMPRA = DateTime.Now
         cprueba.NEUMA_ID = 10
         cprueba.NEUMA_MODELO = "ssssss"
         Dim _f As New ACFramework.ACGenerador(Of ETRAN_VehiculosNeumaticos)("yyyy-MM-dd")
         Dim _where As New Hashtable()
         _where.Add("NEUMA_Id", New ACWhere("", ACWhere.TipoWhere._Like))
         TextBox3.Text = _f.getUpdate("esq", "Tabla", cprueba, _where)
      Catch ex As Exception
         MsgBox("Error")
      End Try
   End Sub
End Class